package com.ruoyi.project.erp.mapper;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;
import com.ruoyi.project.erp.domain.Worklog;
import com.ruoyi.project.erp.dto.WorklogQuery;
import com.ruoyi.project.erp.query.WorklogStatisticsQuery;
import com.ruoyi.project.erp.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 工时Mapper接口
 * 
 * @author ruoyi
 * @date 2025-06-19
 */
public interface WorklogMapper 
{
    /**
     * 查询工时
     * 
     * @param id 工时主键
     * @return 工时
     */
    public Worklog selectWorklogById(Long id);

    /**
     * 查询工时列表
     * 
     * @param worklog 工时
     * @return 工时集合
     */
    public List<Worklog> selectWorklogList(Worklog worklog);

    /**
     * 新增工时
     * 
     * @param worklog 工时
     * @return 结果
     */
    public int insertWorklog(Worklog worklog);

    /**
     * 修改工时
     * 
     * @param worklog 工时
     * @return 结果
     */
    public int updateWorklog(Worklog worklog);

    /**
     * 删除工时
     * 
     * @param id 工时主键
     * @return 结果
     */
    public int deleteWorklogById(Long id);

    /**
     * 批量删除工时
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteWorklogByIds(Long[] ids);

    List<Worklog> selectWorkLogByUserIdAndTaskId(@Param("userId") String userId, @Param("taskId") Long taskId);

    List<MyWorkLogInfoVo> selectMyWorkLogByUserId(String ddUserId);


    Worklog selectMyWorkLogByUserIdAndWorkDate(String userId, Date workDate, Long taskId);

    BigDecimal getWorkLogHoursByUserId(String ddUserId);

    List<Worklog> selectWorklogByTaskId(String taskId);

    BigDecimal selectMyLeftWorkHours(LocalDate workDate, String userId);

    List<WorklogVO> selectList(WorklogQuery query);

    List<WorklogVO> selectExportList(WorklogQuery query);
    /**
     * 根据用户ID和月份查询每日填报的总工时
     *
     * @param userId 用户ID
     * @param beginDate 月份开始日期
     * @param endDate 月份结束日期
     * @return 每日工时统计列表
     */
    public List<WorklogCalendarVO> selectDailyWorklogHours(
            @Param("userId") String userId,
            @Param("beginDate") Date beginDate,
            @Param("endDate") Date endDate
    );

    BigDecimal sumAssignedHoursByUserIdAndDate(String userId, Date workDate);

    void batchInsertWorklog(List<Worklog> worklogsToInsert);

    List<WorklogItemVO> selectSubmittedWorklogItemsVO(String userId, Date workDate);

    List<WorklogStatisticsVO> selectWorklogStatistics(WorklogStatisticsQuery query);

    List<WorklogStatisticsVO> selectPersonalWorklogStatistics(WorklogStatisticsQuery query);

    BigDecimal selectTotalHours(WorklogStatisticsQuery query);

    OvertimeStatisticsVO selectOvertimeStatistics(WorklogStatisticsQuery query);

    ServiceScopeStatisticsVO selectServiceScopeStatistics(WorklogStatisticsQuery query);

    ServiceMethodStatisticsVO selectServiceMethodStatistics(WorklogStatisticsQuery query);

    List<ServiceStageStatisticsVO> selectServiceStageStatistics(WorklogStatisticsQuery query);

    BigDecimal selectPersonalTotalHours(WorklogStatisticsQuery query);
    OvertimeStatisticsVO selectPersonalOvertimeStatistics(WorklogStatisticsQuery query);
    ServiceScopeStatisticsVO selectPersonalServiceScopeStatistics(WorklogStatisticsQuery query);
    ServiceMethodStatisticsVO selectPersonalServiceMethodStatistics(WorklogStatisticsQuery query);
    List<ServiceStageStatisticsVO> selectPersonalServiceStageStatistics(WorklogStatisticsQuery query);
}
